import { _decorator, Component, Node } from 'cc';
import { RoleBase } from '../Object/RoleBase';
const { ccclass, property } = _decorator;

@ccclass('CtrlBase')
export class CtrlBase extends Component {
    //控制器所属对象
    protected _owner: RoleBase = null;
    init(owner: RoleBase) {
        this._owner = owner;
        this.onInit();
    }

    //供派生类重写
    onInit() {

    }

    emit(msgName: string, ...rest: any[]) {
        this._owner.emitter.emit.apply(this._owner.emitter, arguments);
    }

    on(msgName: string, cb: Function, target: any, isOnce: boolean = false) {
        this._owner.emitter.on.apply(this._owner.emitter, arguments);
    }

    onUpdate(dt: number) {

    }
}


